package com.lv.utils.controller;

import com.lv.utils.FeignClient.ResultDate;
import com.lv.utils.FeignClient.TestFeignClient;
import com.lv.utils.FeignClient.TestFeignClient2;
import com.lv.utils.FeignClient.User;
import com.sun.org.apache.regexp.internal.RE;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.beans.factory.annotation.Value;
import org.springframework.web.bind.annotation.*;

import javax.servlet.http.HttpServletRequest;
import java.util.Enumeration;

/**
 * @author: Lv_sc
 * Date:     2021/3/26 17:36
 * Description: 描述
 */
@RestController
@RequestMapping("/test")
public class TestController {

    private final static Logger logger = LoggerFactory.getLogger(TestController.class);

    @Value("${interface.username}")
    private String username;

    @Value("${interface.password}")
    private String password;

    @Autowired
    TestFeignClient testFeignClient;

    @Autowired
    TestFeignClient2 testFeignClient2;

    @PostMapping("/aa")
    public String aa(@RequestBody String body, HttpServletRequest request) {
        String token = request.getHeader("token1");
        logger.info("数据体为：{}",body);
        logger.info("token数据体为：{}",token);
        return "aaa";
    }

    @GetMapping("/getList")
    public String getList() {
        User user = new User(password,username);
        ResultDate login = testFeignClient.login(user);
        String token = login.getToken();
//        String token = "orc1fknjO6eYHNpTpInQcrYNfbhokYAE7X/jKkVOLeVVevvimIRJ2AOUYZDZksO1HeqLKT1K12YHq1sf5x92tqdUnlxM8aAMhOfnyqsA2V9FvE7/RHPcMkl74Trv9PjPUuHRtdulJLpjRRr/uQzfD/h+CSN7doYZxKg1byqJBVZiuf2aukOFXZ++TPa9d1W0m5c2AvAYUU6kVUY68feVB2WKJ36irK3xc71JZVHfJeug8dJmhwD55mNyEmVnz0Pay6PFgUFjvHENZmClZTBLsed1fYz/3cphGEDmxxUNIk+/8hlc6l+dOldmsgzRoh+EodWsmU1NsCxIgJOBPQBrQ40prMZKfXo99Q590meDLkZKipbM3D5aM7SAsNHprjTq319qw62i6eo4HScyk6v47h5t1uFLjxz0FOEa6WkPeSsasj7oIlIir+ZXq29+P9dGNkkvTW934C27IkUwQMhnLqj7c3YswbfDpsbGw3zq9YwG0WjOrZ+mpCKwKPE7kPYgHeQkR/ATF46miuBWsswfkyK9NMDoYzEaYPlIoUibpHQmZU8mXm5BjBrbjMCAsex+Ixf46+3bkEm5l6Gt+Z/99MHcUKN7jt5lmytHvHN/UUwmYwKcW3zX9qOUBSQuwjCK2nGE5fKx5Ra9BBdEmdpZgjvNs7WMO0QDJrNoKgfwszM=";
        logger.info("当前token:{}",token);
        ResultDate w = testFeignClient.getConfigList(token, "W");
        if(w.getCode() == 20022){
            //当前账号在其它终端登录,请注意账号安全!
            logger.error("错误信息",w.getMsg());
            getList();
        }
        return w.getMsg();
    }
    @GetMapping("/getBean")
    public String getBean() {
        ResultDate bean = testFeignClient2.getBean("NIgYmyTHLeCNj7auzn2KTU4vaQa1m0ufP2CNTUkiDPhOyB50dGO2Y3k3nlAcn" +
                "+82jjVbnIR66hNXTsWZgubtv8swIFeO" +
                "+LzfanWmsYrQ7g4wxm3RlreRcBOdw6z8qDIRruKEhy7rrlKZmAHxcz9w3sQ4w9elSsAebiOOivGUUl2LjnUEDgqRPawW8M6bxO93MXX1oAu6NFs3M4We0bkiK24bDbjBBohifcKrGm+0863VpBk4KzJnvGxiBMepqblv3xM35vC4T+r5oVwFr1cpMWar7Jo73/KIML/W4FFfLTXrMPo4qoWN1f358TE34cH9cFIkMdzu3wQqWjt/1Ewvs1bBQwy9fucuCw8GgHHRWdv8l/ru81jC11M18ES4JRBnkjXcqnUpH7/dITe1uofi8Hd1oBi8G7DUKqyylFG1G/Y8Xk8hSk0OZO3m4316MI+iVYWDBlTjaO8n1ePxfOzpLtDV8DwvXLiCxCW5lCHqQMiJuULYUTovQxBQwu4jQVJeW2uY6dNVF8oThydCPP3Xp5smoQZSOMzzRjF5fH9oMP+O53yRVqsB1xwvEa5e7vq11kP29KsQohFJY6WFIzrWG2AyQz7n7g6dPZlkF/Gb/ggYUmwh/AZGeutS+OGVHdy21AtMQ/CmZU8xdjE3mJXgXr1yko5BjiEjUPQ3s6m/9EU=","W","user");
        return "aaa";
    }
}